{ "cells": [ { "attachments": {}, "cell_type": "markdown", "metadata": { "pycharm": { "name": "#%% md\n" } }, "source": [ "# Remote computing with Perceval" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": { "pycharm": { "name": "#%% md\n" } }, "source": [ "Here we aim at showing how to connect to Quandela's cloud services to perform computation with real QPU and simulators remotely. We are going to use a simple two modes circuit here.\n", "\n", "Please note that other Cloud providers exist besides Quandela, see [providers](https://perceval.quandela.net/docs/providers.html) for additional information." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import time\n", "import numpy as np\n", "from tqdm.notebook import tqdm\n", "\n", "import perceval as pcvl\n", "from perceval.algorithm import Sampler" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": { "pycharm": { "name": "#%% md\n" } }, "source": [ "First, define your objects through Perceval as usual." ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "image/svg+xml": [ "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=pi/4\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Rx\n", "\n", "\n", "0\n", "1\n", "0\n", "1\n", "" ], "text/plain": [ "" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "input_state = pcvl.BasicState([1, 1])\n", "\n", "c = pcvl.Circuit(2)\n", "c.add(0, pcvl.BS())\n", "c.add(0, pcvl.PS(phi = np.pi/4))\n", "c.add(0, pcvl.BS())\n", "\n", "pcvl.pdisplay(c)" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": { "pycharm": { "name": "#%% md\n" } }, "source": [ "Now, visit [cloud.quandela.com](https://cloud.quandela.com) and login to see which QPU and simulators are available, as well as their specifications. Once you have chosen, all you have to do is to copy the machine's name. You can now define a `RemoteProcessor` using the name of the machine and your token. Before using your token, don't forget to give it the right to be used on the machine you want." ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "# Use your key here to let the system know who you are\n", "token_qcloud = 'YOUR_API_KEY'\n", "remote_simulator = pcvl.RemoteProcessor(\"sim:ascella\", token_qcloud)" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": { "pycharm": { "name": "#%% md\n" } }, "source": [ "You can now access to the specificities of the machine directly in Perceval." ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "image/svg+xml": [ "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi0\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi1\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi2\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi3\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi4\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi5\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi6\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi7\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi8\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi9\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi10\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi11\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi12\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi13\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi14\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi15\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi16\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi17\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi18\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi19\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi20\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi21\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi22\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi23\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi24\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi25\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi26\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi27\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi28\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi29\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi30\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi31\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi32\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi33\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi34\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi35\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi36\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi37\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi38\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi39\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi40\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi41\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi42\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi43\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi44\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi45\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi46\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi47\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi48\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi49\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi50\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi51\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi52\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi53\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi54\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi55\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi56\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi57\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi58\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi59\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi60\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi61\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi62\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi63\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi64\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi65\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi66\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi67\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi68\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi69\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi70\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi71\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi72\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi73\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi74\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi75\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi76\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi77\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi78\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi79\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi80\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi81\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi82\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi83\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi84\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi85\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi86\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi87\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi88\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi89\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi90\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi91\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi92\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi93\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi94\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi95\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi96\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi97\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi98\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi99\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi100\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi101\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi102\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi103\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi104\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi105\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi106\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi107\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi108\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi109\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi110\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi111\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi112\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi113\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi114\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi115\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi116\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi117\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi118\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi119\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi120\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi121\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi122\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi123\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi124\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi125\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi126\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi127\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi128\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi129\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi130\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Θ=1.440427\n", "\n", "\n", "Rx\n", "\n", "\n", "Φ=phi131\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "0\n", "1\n", "2\n", "3\n", "4\n", "5\n", "6\n", "7\n", "8\n", "9\n", "10\n", "11\n", "0\n", "1\n", "2\n", "3\n", "4\n", "5\n", "6\n", "7\n", "8\n", "9\n", "10\n", "11\n", "" ], "text/plain": [ "" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "specs = remote_simulator.specs\n", "pcvl.pdisplay(specs[\"specific_circuit\"])" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "{'max_mode_count': 12, 'max_photon_count': 6, 'min_mode_count': 1, 'min_photon_count': 1}\n", "{'HOM': 'indistinguishability value, using HOM model (default 1)', 'backend_name': 'name of the backend that will be used for computation (default \"SLOS\")', 'final_mode_number': 'number of modes of the output states. states having a photon on unused modes will be ignored. Useful when using computed circuits (default input_state.m)', 'g2': 'g2 value (default 0)', 'min_detected_photons': 'minimum number of detected photons to keep a state (default input_state.n)', 'phase_imprecision': 'imprecision on the phase shifter phases (default 0)', 'transmittance': 'probability that an emitted photon is sent to the system and is detected (default 1)'}\n" ] } ], "source": [ "print(specs[\"constraints\"])\n", "print(specs[\"parameters\"])" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": { "pycharm": { "name": "#%% md\n" } }, "source": [ "Now we have to specify what parameters we want to give to compute. For specific parameters, we have to use a special `set_parameter` function (or `set_parameters`)." ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "remote_simulator.set_circuit(c)\n", "remote_simulator.with_input(input_state)\n", "\n", "remote_simulator.set_parameters({\n", " \"HOM\": .95,\n", " \"transmittance\": .1,\n", " \"g2\": .01\n", "})\n", "remote_simulator.min_detected_photons_filter(1)" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": { "pycharm": { "name": "#%% md\n" } }, "source": [ "We can now use the `Sampler` with our `RemoteProcessor`." ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [], "source": [ "sampler = Sampler(remote_simulator)\n", "sampler.default_job_name = \"My sampling job\" # All jobs created by this sampler instance will have this custom name on the cloud\n", "\n", "nsample = 200000\n", "remote_job = sampler.sample_count.execute_async(nsample)" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": { "pycharm": { "name": "#%% md\n" } }, "source": [ "The order has now been sent to a distant computer. As it is an async computation, we can do other things locally before the results arrive. In our case, we will just wait for the end of the computation. If you go to the cloud website again, you could see the job and its completion status." ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "fa3e0674763d422aad8e3fc4aa7ba725", "version_major": 2, "version_minor": 0 }, "text/plain": [ " 0%| |" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "Job status = SUCCESS\n" ] } ], "source": [ "previous_prog = 0\n", "with tqdm(total=1, bar_format='{desc}{percentage:3.0f}%|{bar}|') as tq:\n", " tq.set_description(f'Get {nsample} samples from {remote_simulator.name}')\n", " while not remote_job.is_complete:\n", " tq.update(remote_job.status.progress/100-previous_prog)\n", " previous_prog = remote_job.status.progress/100\n", " time.sleep(1)\n", " tq.update(1-previous_prog)\n", " tq.close()\n", "\n", "print(f\"Job status = {remote_job.status()}\")" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": { "pycharm": { "name": "#%% md\n" } }, "source": [ "Once the previous cell has stopped, the job is finished (again, you can see its status on the website). We can now retrieve the results to do some computation. Here, the computation should be relatively fast (unless the simulator is unavailable or there are many requests on it), so we can use the job object we created before. If the computation lasted for a long time, we could have created a new job object and directly retrieved the result given the job id that is visible on the website." ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "{\n", " |1,0>: 99022\n", " |0,1>: 98858\n", " |1,1>: 2120\n", "}\n" ] } ], "source": [ "''' # To retrieve your job using a job id\n", "remote_processor = pcvl.RemoteProcessor(\"sim:ascella\", token_qcloud)\n", "async_job = remote_processor.resume_job(id)\n", "'''\n", "\n", "results = remote_job.get_results()\n", "print(results['results'])" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": { "pycharm": { "name": "#%% md\n" } }, "source": [ "You can run the same sampling on the corresponding QPU:" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [], "source": [ "remote_qpu = pcvl.RemoteProcessor(\"qpu:ascella\", token_qcloud)\n", "remote_qpu.set_circuit(c)\n", "remote_qpu.with_input(input_state)\n", "remote_qpu.min_detected_photons_filter(1)\n", "\n", "sampler_on_qpu = Sampler(remote_qpu)\n", "\n", "nsample = 200000\n", "remote_job = sampler_on_qpu.sample_count\n", "remote_job.name = \"QPU sampling\" # You may also specify a name to individual jobs\n", "remote_job.execute_async(nsample);" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "95d6787d6d064282a327870a91a3a445", "version_major": 2, "version_minor": 0 }, "text/plain": [ " 0%| |" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "Job status = SUCCESS\n" ] } ], "source": [ "previous_prog = 0\n", "with tqdm(total=1, bar_format='{desc}{percentage:3.0f}%|{bar}|') as tq:\n", " tq.set_description(f'Get {nsample} samples from {remote_qpu.name}')\n", " while not remote_job.is_complete:\n", " tq.update(remote_job.status.progress/100-previous_prog)\n", " previous_prog = remote_job.status.progress/100\n", " time.sleep(1)\n", " tq.update(1-previous_prog)\n", " tq.close()\n", "\n", "print(f\"Job status = {remote_job.status()}\")" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "{\n", " |1,0>: 211538\n", " |0,1>: 178621\n", " |1,1>: 5013\n", "}\n" ] } ], "source": [ "results = remote_job.get_results()\n", "print(results['results'])" ] } ], "metadata": { "language_info": { "name": "python" } }, "nbformat": 4, "nbformat_minor": 1 }